home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Enlighten DSM 3.1
/
SGI EnlightenDSM 3.1.iso
/
SCO5X
/
ADMIN
/
bin
/
enl_delegate
< prev
next >
Wrap
Text File
|
1999-04-16
|
7KB
|
315 lines
#!/bin/sh
#
# Copyright (c) 1990-1999 Enlighten Software Solutions, Inc.
#
# Script: enl_delegate
# Usage : enl_delegate -q -[enable|disable]
#
# -q : run in quiet mode. User is not prompted for confirmation
# and no output is displayed.
# -enable: Permissions on EnlightenDSM's directories and files
# are modified so that any authorized user may access
# and run the product.
# -disable : Permissions on EnlightenDSM's directories and files
# are modified so that only user root may access and run
# the product.
#
# Exit code: 0 on success, 1 on failure
#
Usage () {
echo
echo "enl_delegate -q -[enable|disable]"
echo
echo "-? : Display usage statement and exit."
echo "-q : Run in quiet mode. User is not prompted for confirmation"
echo " and no output is displayed."
echo "-enable : Permissions on EnlightenDSM's directories and files"
echo " are modified so that any authorized user may access"
echo " and run the product."
echo "-disable: Permissions on EnlightenDSM's directories and files"
echo " are modified so that only user root may access and run"
echo " the product."
echo
echo "Return code: 0 on success, 1 on failure"
echo
}
change_dir_mode () {
msg="\nChanging the following directories to mode $curr_mode:"
print_msg
for i in $curr_list
do
if [ -d "${prod_dir}/$i" ] ; then
chmod $curr_mode ${prod_dir}/$i
msg=${prod_dir}/$i
print_msg
fi
done
}
change_dir_star_mode () {
msg="\nChanging contents of the following directories to mode $curr_mode:"
print_msg
for i in $curr_list
do
if [ -d "${prod_dir}/$i" ] ; then
find ${prod_dir}/$i -exec chmod $curr_mode {} \;
msg=${prod_dir}/$i
print_msg
fi
done
}
change_file_mode () {
msg="\nChanging the following files to mode $curr_mode:"
print_msg
for i in $curr_list
do
if [ -f "${prod_dir}/$i" ] ; then
chmod $curr_mode ${prod_dir}/$i
msg=${prod_dir}/$i
print_msg
fi
done
}
change_file_bin_mode () {
msg="\nChanging the following files to mode $curr_mode:"
print_msg
for i in $curr_list
do
if [ -f "${prod_dir}/bin/$i" ] ; then
chmod $curr_mode ${prod_dir}/bin/$i
msg=${prod_dir}/bin/$i
print_msg
fi
done
}
print_msg () {
if [ "$quiet" -eq 0 ] ; then
echo $msg
fi
echo $msg >> $log
}
############## Start of script #####################
app_name=`basename $0`
time=`date`
quiet=0
enable=0
is_set=0
# Verify user is root
user_id=`id | tr "(" "=" | cut "-d=" -f2`
if [ "$user_id" -ne 0 ] ; then
echo "$app_name must be run by user root."
echo "Exiting..."
exit 1
fi
# Get command line arguments
if [ "$#" -lt 1 ] ; then
Usage
exit 1
fi
while [ "$#" -ne 0 ] ; do
case "$1" in
-q )
quiet=1
;;
-enable )
enable=1
is_set=1
action="Enabling"
;;
-disable )
enable=0
is_set=1
action="Disabling"
;;
-? )
Usage
exit 0
;;
* )
echo "Unknown option: $1"
Usage
exit 1
;;
esac
shift
done
if [ "$is_set" -eq 0 ] ; then
echo "You must specify -enable or -disable."
Usage
exit 1
fi
# Get install directory
prod_dir=`egrep "^enlighten=" /etc/enlighten | cut "-d=" -f2-`
if [ -z "$prod_dir" -o ! -d "$prod_dir" ] ; then
echo "Unable to find EnlightenDSM installation directory."
echo "Check the settings in /etc/enlighten file for errors."
exit 1
fi
log=${prod_dir}/logs/${app_name}.log
# Double check with user
if [ "$quiet" -eq 0 ] ; then
echo "$action delegation of authority for EnlightenDSM."
echo 'Do you wish to continue? (y/n): '
read ans
case $ans in
y* | Y* )
;;
* )
echo "Exiting..."
exit 0
;;
esac
fi
# Define directories and files to be modified
dirs_750=". bin config config/formlet msg msg/C icons icons/C help help/C config/rfd config/backup maps"
dirs_770=".data tmp logs config/defaultpool config/backup/logfiles config/rfd/logfiles secure work"
files_bin_710="xenln sm p_snapdiff hexed"
dirs_star_440="maps icons/C msg/C help/C"
files_440="config/params config/cmds config/defnetgrp"
dirs_star_660="config/formlet config/backup/logfiles config/rfd/logfiles"
files_640="config/winn.out config/names config/remedies config/suggestions"
dirs_700="$dirs_750 $dirs_770"
dirs_star_400=$dirs_star_440
dirs_star_600=$dirs_star_660
files_600="$files_640"
files_400="$files_440"
files_bin_700=$files_bin_710
if [ "$enable" -eq 1 ] ; then
echo "" >> $log
echo "" >> $log
echo "#####################################################" >> $log
msg="$app_name: Enabling delegation of authority on $time."
print_msg
# Change the directories
curr_list=$dirs_star_440
curr_mode="440"
change_dir_star_mode
curr_list=$dirs_star_660
curr_mode="660"
change_dir_star_mode
curr_list=$dirs_750
curr_mode="750"
change_dir_mode
curr_list=$dirs_770
curr_mode="770"
change_dir_mode
# Change the files
curr_list=$files_bin_710
curr_mode="710"
change_file_bin_mode
curr_list=$files_640
curr_mode="640"
change_file_mode
curr_list=$files_440
curr_mode="440"
change_file_mode
if [ "$quiet" -eq 0 ] ; then
echo ""
echo "********************************************"
echo "Finished enabling delegation of authority."
echo "To control user access to EnlightenDSM, use the"
echo "User Authorization window available from the Configure Menu"
echo "of the EnlightenDSM GUI."
echo "Authorized users must also be placed in group 'enldsm'"
echo "in order to have access to the EnlightenDSM GUI."
echo ""
echo "A log of actions performed by this script can be found in"
echo "$log."
fi
else
# Enable root only access
echo "" >> $log
echo "" >> $log
echo "#####################################################" >> $log
msg="$app_name: Disabling delegation of authority on $time."
print_msg
curr_list=$dirs_700
curr_mode="700"
change_dir_mode
curr_list=$dirs_star_400
curr_mode="400"
change_dir_star_mode
curr_list=$dirs_star_700
curr_mode="700"
change_dir_star_mode
curr_list=$dirs_star_600
curr_mode="600"
change_dir_star_mode
curr_list=$files_600
curr_mode="600"
change_file_mode
curr_list=$files_400
curr_mode="400"
change_file_mode
curr_list=$files_bin_700
curr_mode="700"
change_file_bin_mode
if [ "$quiet" -eq 0 ] ; then
echo ""
echo "********************************************"
echo "Finished disabling delegation of authority."
echo ""
echo "A log of actions performed by this script can be found in"
echo "$log."
fi
fi